﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace OpenANDClose
{
    class Program
    {
        static void Main(string[] args)
        {
           // string command="控制灯";
           //string command ="控制风扇";
           //string command= "控制空调";
            string command="控制多媒体";
            cl_0423_DevicePackage alllights;
            cl_0423_Device light1, light2, fan, air, mt;
            alllights = new cl_0423_DevicePackage();
            light1 = new cl_0423_Light();
            light2 = new cl_0423_Light();
            fan = new cl_0423_Fan();
            air = new cl_0423_AirCondition();
            mt = new cl_0423_Multimedia();
            alllights.addDevice(light1);
            alllights.addDevice(light2);

            cl_0423_Command lightsOpenCommand, lightsCloseCommand, fansOpenCommand, fansCloseCommand,
            airsOpenCommand, airsCloseCommand, mtsOpenCommand, mtsCloseCommand;

            lightsOpenCommand = new cl_0423_OpenCommand(alllights);
            lightsCloseCommand = new cl_0423_CloseCommand(alllights);
            fansOpenCommand = new cl_0423_OpenCommand(fan);
            fansCloseCommand = new cl_0423_CloseCommand(fan);
            airsOpenCommand = new cl_0423_OpenCommand(air);
            airsCloseCommand = new cl_0423_CloseCommand(air);
            mtsOpenCommand = new cl_0423_OpenCommand(mt);
            mtsCloseCommand = new cl_0423_CloseCommand(mt);

            cl_0423_Controller controller = new cl_0423_Controller(lightsOpenCommand, lightsCloseCommand, fansOpenCommand, fansCloseCommand,
            airsOpenCommand, airsCloseCommand, mtsOpenCommand, mtsCloseCommand);

            Console.WriteLine("使用者选择" + command);
            if (command == "控制灯")
            {       
                controller.openLights();
                controller.closeLights();
            }else if (command == "控制风扇")
            {
                controller.openFans();
                controller.closeFans();
            }

            if (command == "控制空调")
            {
                controller.openAirConditions();
                controller.closeAirConditions();
            }else if (command == "控制多媒体")
            {
                controller.openMultimedias();
                controller.closeMultimedias();
            }
           

            Console.ReadKey();
        }
    }
}
